#include "fractal.h"

Fractal::Fractal()
{
}

Fractal::~Fractal()
{

}

void Fractal::run()
{
    generate();
}

double Fractal::distZ(double x)
{
    return std::min(x - floor(x), floor(x+1) - x);
}

double Fractal::distZE(double x)
{
    int Zx = floor(x);

    if (Zx % 2 == 0)
    {
        return distZ(x);
    }
    else
    {
        return -distZ(x);
    }
}

double Fractal::distZO(double x)
{
    int Zx = floor(x);

    if (Zx % 2 != 0)
    {
        return distZ(x);
    }
    else
    {
        return -distZ(x);
    }
}

double Fractal::distZDM(double x)
{
    int Zx = floor(x);

    if (x - Zx <= 0.5)
    {
        return distZ(x);
    }
    else
    {
        return -distZ(x);
    }
}
